package com.spring.model_attribute;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * ModelAttribute的使用
 */
@Controller
public class MController {
	/**
	 * initModel()中对该方法的map进行赋值，放入mv的model中，再执行目标方法
	 * @param map
	 */
	@ModelAttribute
	public void getUser(Map map){
		System.out.println("getuser");
		map.put("name","chen3222");
	}

	@RequestMapping("/m")
	public String m(){
		System.out.println("hehe");
		return "hello";
	}
	@RequestMapping("/h")
	public String j(){
		System.out.println("hehe3");
		return "hello";
	}
}
